<template>
  <div>
    <div class="bottom">
      <ul>
        <li>
          <img
            v-if="active == 1"
            @click="MyTabbarclick"
            src="@\assets\image\icon\f_index_show.png"
            alt=""
          /><img
            v-else
            @click="MyTabbarclick"
            src="@\assets\image\icon\f_index_hide.png"
            alt=""
          /><span>首页</span>
        </li>
        <li>
          <img
            v-if="active == 2"
            @click="MyTabbarclick"
            src="@\assets\image\icon\f_Course_show.png"
            alt=""
          />
          <img
            v-else
            @click="CouresListclick"
            src="@\assets\image\icon\f_Course_hide.png"
            alt=""
          /><span>课程</span>
        </li>
        <li>
          <img
            v-if="active == 3"
            @click="Achievementsclick"
            src="@\assets\image\icon\f_Achievements_show.png"
            alt=""
          />
          <img
            v-else
            @click="Achievementsclick"
            src="@\assets\image\icon\f_Achievements_hide.png"
            alt=""
          />
          <span>成长</span>
        </li>
        <li>
          <img
            v-if="active == 4"
            @click="Mineclick"
            src="@\assets\image\icon\f_mine_show.png"
            alt=""
          />
          <img
            v-else
            @click="Mineclick"
            src="@\assets\image\icon\f_mine_hide.png"
            alt=""
          />
          <span>我的</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: sessionStorage.getItem("homePage") || 1,
    };
  },
  methods: {
    MyTabbarclick() {
      // console.log(1);
      this.active = 1;
      sessionStorage.setItem("homePage", 1);
      this.$router.push("/home/Index");
    },
    CouresListclick() {
      // console.log(1);
      this.active = 2;
      sessionStorage.setItem("homePage", 2);
      this.$router.push("/home/CouresList");
    },
    Achievementsclick() {
      // console.log(1);
      this.active = 3;
      sessionStorage.setItem("homePage", 3);
      this.$router.push("/home/Achievements");
    },
    Mineclick() {
      // console.log(1);
      this.active = 4;
      sessionStorage.setItem("homePage", 4);
      this.$router.push("/home/Mine");
    },
  },
};
</script>

<style lang="less" scoped>
body {
  background-color: white;
}
.bottom {
  position: fixed;
  width: 100%;
  bottom: 0;
  padding-bottom: 5px;
  background-color: white;
  ul {
    display: flex;
    justify-content: space-between;
    height: 100%;
    border-top: 1px solid #ccc;
    box-shadow: 0 -5px 10px -10px #000;
    li {
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      font-size: 0.26667rem;
      padding-top: 10px;
      span {
        font-size: 13px;
      }
      img {
        height: 30px;
      }
    }
  }
}
</style>
